"""
    Coupon type contoller.
"""

from mnemoply import model
from mnemoply.controllers.lookup import LookupController, TableCol, SQLObjectLookupDataSource
from mnemoply.controllers.crud import CRUDController

class CouponTypeController(LookupController, CRUDController):
    model_object = model.CouponType
    lookup_columns = [
        TableCol(name='name', caption=_('Name')),
        TableCol(name='nominal', caption=_('Nominal')),
        TableCol(name='comment', caption=_('Comment'), hidden=True),
        TableCol(name='year', caption=_("Year"), size=4),
    ]
    view_fields = [
        'name',
        'nominal',
        'comment',
        'year',
    ]

    def __init__(self):
        LookupController.__init__(
            self,
            data_source=SQLObjectLookupDataSource(self.model_object),
            columns=self.lookup_columns,
            title=self.model_object.model_title,
            )
        CRUDController.__init__(self, model_object=self.model_object)

exposed = CouponTypeController()